package com.cdream.basic.classloader;

public class ClassLoaderExample {
    public static void main(String[] args) throws ClassNotFoundException {
        // getResource();

        ClassLoaderExample.class.getClassLoader().loadClass("com.cdream.basic.classloader.model.Robot");
        System.out.println("loadClass完成了");
        Class.forName("com.cdream.basic.classloader.model.Robot");
        System.out.println("forName完成了");

    }


    /**
     * 通过类路径来获取资源
     */
    private static void getResource() {
        System.out.println(ClassLoaderExample.class.getResource("application.properties"));
        System.out.println(ClassLoaderExample.class.getResource("/application.properties"));
        System.out.println(ClassLoaderExample.class.getClassLoader().getResource("application.properties"));
        System.out.println(ClassLoaderExample.class.getClassLoader().getResource("/application.properties"));
    }

}
